package co.yixiang.upms.common.logging.hystix;


import co.yixiang.common.core.api.ApiResult;
import co.yixiang.upms.common.logging.domain.Log;
import co.yixiang.upms.common.logging.feign.RemoteLoggingService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 *日志服务降级处理
 * @author yshop
 */
@Component
public class RemoteLoggingFallbackFactory implements FallbackFactory<RemoteLoggingService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteLoggingFallbackFactory.class);

    @Override
    public RemoteLoggingService create(Throwable throwable)
    {
        log.error("日志付服务调用失败:{}", throwable.getMessage());
        return new RemoteLoggingService()
        {
            @Override
            public ApiResult save(Log map) {
                return null;
            }
        };
    }
}
